package org.linlinjava.litemall.db.service;

import com.github.yulichang.base.MPJBaseServiceImpl;
import org.linlinjava.litemall.db.dao.LumiereSubscribeGoodsMapper;
import org.linlinjava.litemall.db.domain.LitemallSubscribeGoods;
import org.linlinjava.litemall.db.domain.LitemallSubscribeGoodsExample;
import org.linlinjava.litemall.db.domain.LumiereSubscribeGoods;
import org.linlinjava.litemall.db.domain.LumiereSubscribeGoodsExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LumiereSubscirbeGoodsService extends MPJBaseServiceImpl<LumiereSubscribeGoodsMapper,LumiereSubscribeGoods> {

    @Resource
    private LumiereSubscribeGoodsMapper lumiereSubscribeGoodsMapper;

    public void add(LumiereSubscribeGoods lumiereSubscribeGoods){
        lumiereSubscribeGoodsMapper.insertSelective(lumiereSubscribeGoods);
    }

    public void update(LumiereSubscribeGoods lumiereSuscribeGoods){
        lumiereSubscribeGoodsMapper.updateByPrimaryKey(lumiereSuscribeGoods);
    }

    public List<LumiereSubscribeGoods>  querySubscribeGoodsById(Integer subscribeId){
        LumiereSubscribeGoodsExample example = new LumiereSubscribeGoodsExample();
        example.or().andSubscribeIdEqualTo(subscribeId);
        return  lumiereSubscribeGoodsMapper.selectByExampleSelective(example);
    }

    public LumiereSubscribeGoods queryOne(LumiereSubscribeGoodsExample example){
       return  lumiereSubscribeGoodsMapper.selectOneByExample(example);
    }

    public LumiereSubscribeGoods findByGoodsIdAndSubId(Integer goodsId, Integer subscribeId) {
        LumiereSubscribeGoodsExample example = new LumiereSubscribeGoodsExample();
        example.or().andDeletedEqualTo(false).andSubscribeIdEqualTo(subscribeId).andGoodsIdEqualTo(goodsId);
        return lumiereSubscribeGoodsMapper.selectOneByExample(example);
    }

    public List<LumiereSubscribeGoods> queryLumiereSubscribeById(Integer subscribeId){
        LumiereSubscribeGoodsExample example = new LumiereSubscribeGoodsExample();
        example.or().andDeletedEqualTo(false).andSubscribeIdEqualTo(subscribeId);
        return lumiereSubscribeGoodsMapper.selectByExample(example);
    }

    public void deleteBySubscribeId(Integer subscribeId){
        LumiereSubscribeGoodsExample example = new LumiereSubscribeGoodsExample();
        example.or().andSubscribeIdEqualTo(subscribeId);
        lumiereSubscribeGoodsMapper.deleteByExample(example);
    }

    public LumiereSubscribeGoods findById(Integer id) {
        return lumiereSubscribeGoodsMapper.selectByPrimaryKey(id);
    }

    public LumiereSubscribeGoods findBySubIdAndGoodId(Integer subscribeId, Integer goodsId) {
        LumiereSubscribeGoodsExample example = new LumiereSubscribeGoodsExample();
        example.or().andSubscribeIdEqualTo(subscribeId).andGoodsIdEqualTo(goodsId).andDeletedEqualTo(false);
        return lumiereSubscribeGoodsMapper.selectOneByExample(example);
    }
}
